<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<% 
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%> 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection"
	content="telephone=no,email=no,date=no,address=no">
<title></title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/aui.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/aui-pull-refresh.css" />
<style>
.aui-content-padded {
	padding: 0.75 rem;
	background-color: #ffffff;
	margin-top: 0.75 rem;
}

.aui-card-list-footer>* {
	position: absolute;
	right: 30px;
	bottom: 10px;
}
</style>
</head>
<body>
	<section class="aui-content-padded" style="margin:0;">
			<div class="titles" style="padding:1rem 1.25rem;">
				<h1 id="activityName" ></h1>
				<p style="font-size:0.8rem;margin-top:0.2rem;" id="deptName" >
				</p>
			</div>
			<ul class="aui-list aui-form-list">
				<li class="aui-list-item">
					<div class="aui-list-item-inner">
						<div class="aui-list-item-label">
							开始时间:
						</div>
						<div class="aui-list-item-input">
							<span id="startDate"></span>
						</div>
					</div>
				</li>
				<li class="aui-list-item">
					<div class="aui-list-item-inner">
						<div class="aui-list-item-label">
							结束时间:
						</div>
						<div class="aui-list-item-input">
							<span id="endDate"></span>
						</div>
					</div>
				</li>
				<li class="aui-list-item">
					<div class="aui-list-item-inner">
						<div class="aui-list-item-label">
							活动地点:
						</div>
						<div class="aui-list-item-input">
							<span id="address"></span>
						</div>
					</div>
				</li>
				<li class="aui-list-item">
					<div class="aui-list-item-inner">
						<div class="aui-list-item-label">
							活动人数:
						</div>
						<div class="aui-list-item-input">
							<span id="limitNumber"></span>人
						</div>
					</div>
				</li>
			</ul>
			<p id="activityContent" style="padding:1rem 1.25rem;font-size:0.85rem;text-indent: 2em;">
			</p>
	<p style="text-align: center; ">扫码预约活动</p>
	<div id="code" style="text-align: center; margin-top: 20px; margin-bottom: 20px;"></div>
		<div style="text-align: center; margin-top: 20px; margin-bottom: 20px;">
		<img id='imgOne' style='margin: 0 auto;padding-bottom: 10px;' />
	</div>
	</section>
	<div class="aui-toast" style="display: none;" id="loading">
		<div class="spinner aui-toast-content">
			<div class="spinner-container container1">
				<div class="circle1"></div>
				<div class="circle2"></div>
				<div class="circle3"></div>
				<div class="circle4"></div>
			</div>
			<div class="spinner-container container2">
				<div class="circle1"></div>
				<div class="circle2"></div>
				<div class="circle3"></div>
				<div class="circle4"></div>
			</div>
			<div class="spinner-container container3">
				<div class="circle1"></div>
				<div class="circle2"></div>
				<div class="circle3"></div>
				<div class="circle4"></div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.qrcode.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
	//活动id
	var id = "${param.id}";
	var empid = "${param.empid}";
	var basePath = "<%=basePath%>";
	
	
	var joinUrl = basePath+"insertInviteSign.do?activityId=${param.id}&empId=${param.empid}&section=0";
 	
	//var fxpath=joinUrl;
	var timestamp="";
	var url=window.location.href;
	
	var titile = "滨海基金-活动分享";
	//初始方法
	$(function() {
	
		$.ajax({
			url : '${pageContext.request.contextPath}/weixin/jsapi_sign.htm',
			type : "GET",
			data : {
				"url" : url
			},
			dataType : "json",
			success : function(data) {
				// alert("SUCCESS");
				if (data) {
					timestamp = data.timestamp;
					nonceStr = data.nonceStr;
					signature = data.signature;
					wx.config({
						debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
						appId : data.appId, // 必填，公众号的唯一标识
						timestamp : timestamp, // 必填，生成签名的时间戳
						nonceStr : nonceStr, // 必填，生成签名的随机串
						signature : signature, // 必填，签名，见附录1
						jsApiList : [ 'onMenuShareTimeline', 'onMenuShareAppMessage', 'hideMenuItems' ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
					});
				}
			}
		});
		
			wx.ready(function() {
			wx.checkJsApi({
				jsApiList : [ 'onMenuShareTimeline', 'onMenuShareAppMessage', 'hideMenuItems' ], // 需要检测的JS接口列表，所有JS接口列表见附录2,
				success : function(res) 
				{
					//alert(JSON.stringify(res));
					//alert(basePath+"img/bing.png");
					//alert(basePath + "wap/market_detailed_body.do?id=${param.id}&empId=${param.empid}");
				}
			});
			wx.onMenuShareAppMessage({
				title : titile, // 分享标题
				desc : '滨海基金是专业的投融资服务机构,经过坚持不懈的拓展和资本市场的历练，公司已成为股权投资和资产管理产业链完备、服务品种丰富、为客户创造最佳价值的本土投资机构之一。', // 分享描述
				link : basePath + "wap/market_detailed_body.do?id=${param.id}&empId=${param.empid}", // 分享链接
				imgUrl : basePath+"img/bing.png", // 分享图标
				type : '', // 分享类型,music、video或link，不填默认为link
				dataUrl : '', // 如果type是music或video，则要提供数据链接，默认为空
				success : function() {
					// 用户确认分享后执行的回调函数
					alert("分享成功！")
				},
				cancel : function() {
					// 用户取消分享后执行的回调函数
					alert("分享被取消！")
				}
			});
			wx.hideMenuItems({
				menuList : [ 'menuItem:share:qq', 'menuItem:share:weiboApp', 'menuItem:favorite', 'menuItem:share:QZone', 'menuItem:copyUrl', 'menuItem:editTag', 'menuItem:openWithQQBrowser' ] // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
			});
		});

		//添加分享浏览记录
		$.ajax({
			url : '${pageContext.request.contextPath}/insertSharingRecords.do',
			type : "POST",
			dataType : "json",
			data : {
				"contentId" : id,
				"empId" : empid,
				"contentType" : 0,
				"sharingType" : 1
			},
			success : function(data) {}
		});


		$.ajax({
			url : '${pageContext.request.contextPath}/appcrm/activityDetail.do?id=' + id,
			type : "POST",
			dataType : "json",
			success : function(data) {
				var ret = data;
				if (ret.code == 0) {
					if (typeof (ret.activity) != "undefined") {
						titile = ret.activity.deptName+"-活动分享";
						
						$("#deptName").html(ret.activity.deptName);
						//$("#createDate").html(toDate(ret.activity.createDate));
						$("#activityName").html(ret.activity.activityName);
						$("#activityContent").html(ret.activity.activityContent);
						$("#address").html(ret.activity.address);
						$("#startDate").html(toDateTime(ret.activity.startDate));
						$("#endDate").html(toDateTime(ret.activity.endDate));
						$("#limitNumber").html(ret.activity.limitNumber);
					}
				} else {
					alert("暂无数据!");
				}
			}
		});

		var qrcode = $("#code").qrcode({
			render : "canvas", //table方式 
			width : 100, //宽度 
			height : 100, //高度 
			text : joinUrl //参加活动。
		});
		
		
		
		//默认使用Canvas生成，并显示到图片   
		//var qrcode= $('#divOne').qrcode('http://www.gongjuji.net/').hide();  
		qrcode.hide();
		var canvas = qrcode.find('canvas').get(0);
		$('#imgOne').attr('src', canvas.toDataURL('image/jpg'))
		//$('#code').qrcode("http://www.helloweba.com"); //任意字符串 
	});
	
	
	/**
	 *转换时间格式yyyy-MM-dd
	 */
	function toDateTime(data) {
		var date = new Date(data);
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		var hour = date.getHours();
		var minute = date.getMinutes();
		m = m < 10 ? '0' + m : m;
		var d = date.getDate();
		d = d < 10 ? ('0' + d) : d;
		hour = hour < 10 ? '0' + hour
				: hour;
		minute = minute < 10 ? '0'
				+ minute : minute;
		return y + '-' + m + '-' + d + " " + hour + ":" + minute;
	}
	
	
 
	
	
	
</script>
</html>